'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	const $ = db.command.aggregate
	const collection = db.collection('company_collect');
	const res = await collection
		.aggregate()
		.match({'company':event.company})
		.group({
			_id: '$advice',
			data: $.sum(1)
		})
		.end();
	return {
		data: res.data || []
	};
};
